package com.yoga.manager.beanUtil;

import com.yoga.common.bo.PlainVipBO;
import com.yoga.dao.domain.PlainVipDO;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 类PlainVipBeanUtil.java的实现描述：工具类
 * 
 * @Author hdx
 * @Date 2020年09月24日
 */
public class PlainVipBeanUtil {

    private PlainVipBeanUtil(){
    }

    public static PlainVipDO plainVipBOToDO(PlainVipBO srcObj) {
        if (srcObj == null) {
            return null;
        }
        PlainVipDO targetObj = new PlainVipDO();
        targetObj.setId(srcObj.getPlainVipId());//id
        targetObj.setYogaUserId(srcObj.getYogaUserId());//用户id
        targetObj.setVipType(srcObj.getVipType());//0、未开通，1、团课会员, 2、次卡，
        targetObj.setVipStartDate(srcObj.getVipStartDate());//vip开始日期(默认2020-01-01)
        targetObj.setVipEndDate(srcObj.getVipEndDate());//vip结束日期(默认2020-01-01)
        targetObj.setVipPrice(srcObj.getVipPrice());//vip价格
        targetObj.setTotalPrice(srcObj.getTotalPrice());//累计消费金额
        targetObj.setClassNum(srcObj.getClassNum());//课数量
        targetObj.setAboutNum(srcObj.getAboutNum());//已约次数
        targetObj.setStopEndDate(srcObj.getStopEndDate());//停卡结束日期
        targetObj.setDeleteMark(srcObj.getDeleteMark());//0、正常，1、删除
        targetObj.setCreateTime(srcObj.getCreateTime());
        targetObj.setUpdateTime(srcObj.getUpdateTime());
        return targetObj;
    }

    public static PlainVipBO plainVipDOToBO(PlainVipDO srcObj) {
        if (srcObj == null) {
            return null;
        }
        PlainVipBO targetObj = new PlainVipBO();
        targetObj.setPlainVipId(srcObj.getId());//id
        targetObj.setYogaUserId(srcObj.getYogaUserId());//用户id
        targetObj.setVipType(srcObj.getVipType());//0、未开通，1、团课会员, 2、次卡，
        targetObj.setVipStartDate(srcObj.getVipStartDate());//vip开始日期(默认2020-01-01)
        targetObj.setVipEndDate(srcObj.getVipEndDate());//vip结束日期(默认2020-01-01)
        targetObj.setVipPrice(srcObj.getVipPrice());//vip价格
        targetObj.setTotalPrice(srcObj.getTotalPrice());//累计消费金额
        targetObj.setClassNum(srcObj.getClassNum());//课数量
        targetObj.setAboutNum(srcObj.getAboutNum());//已约次数
        targetObj.setStopEndDate(srcObj.getStopEndDate());//停卡结束日期
        targetObj.setDeleteMark(srcObj.getDeleteMark());//0、正常，1、删除
        targetObj.setCreateTime(srcObj.getCreateTime());
        targetObj.setUpdateTime(srcObj.getUpdateTime());
        return targetObj;
    }

    public static List<PlainVipBO> doList2BOList(List<PlainVipDO> doList) {
        List<PlainVipBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }
        doList.stream().forEach(plainVipDO -> boList.add(PlainVipBeanUtil.plainVipDOToBO(plainVipDO)));
        return boList;
    }
}